import mallApi from '@/api/declaration/mall/mallApi'
import httpRequest from '@/config/axios/httpRequest'
import { PropertyModel, PropertyValueModel } from '@/models/mall/PropertyModel'

// ------------------------ 属性项 -------------------

// 创建属性项
export const createProperty = (data: PropertyModel) => {
  return httpRequest.post(mallApi.CreateProperty, data)
}

// 更新属性项
export const updateProperty = (data: PropertyModel) => {
  return httpRequest.put(mallApi.UpdateProperty, data)
}

// 删除属性项
export const deleteProperty = (id: number) => {
  return httpRequest.delete(mallApi.DeleteProperty, { params: { id } })
}

// 获得属性项
export const getProperty = (id: number) => {
  return httpRequest.get(mallApi.GetProperty, { params: { id } })
}

// 获得属性项分页
export const getPropertyPage = (params: PageParam) => {
  return httpRequest.get(mallApi.GetPropertyPage, { params })
}

// 获得属性项精简列表
export const getPropertySimpleList = () => {
  return httpRequest.get(mallApi.GetPropertySimpleList)
}

// ------------------------ 属性值 -------------------

// 获得属性值分页
export const getPropertyValuePage = (params: PageParam & any) => {
  return httpRequest.get(mallApi.GetPropertyValuePage, { params })
}

// 获得属性值
export const getPropertyValue = (id: number) => {
  return httpRequest.get(mallApi.GetPropertyValue, { params: { id } })
}

// 创建属性值
export const createPropertyValue = (data: PropertyValueModel) => {
  return httpRequest.post(mallApi.CreatePropertyValue, data)
}

// 更新属性值
export const updatePropertyValue = (data: PropertyValueModel) => {
  return httpRequest.put(mallApi.UpdatePropertyValue, data)
}

// 删除属性值
export const deletePropertyValue = (id: number) => {
  return httpRequest.delete(mallApi.DeletePropertyValue, { params: { id } })
}

// 获得属性值精简列表
export const getPropertyValueSimpleList = (propertyId: number) => {
  return httpRequest.get(mallApi.GetPropertyValueSimpleList, { params: { propertyId } })
}
